<div class="el-dialog__header">
    <button type="button" data-dismiss="modal" aria-hidden="true" aria-label="Close" class="el-dialog__headerbtn"><i
            class="el-dialog__close el-icon el-icon-close"></i></button>
    <h4 class="modal-title">${msg['index.custommenu']}</h4>
</div>
<div class="modal-body">
    <div class="list-group" style="text-align: center;">
        <table width="88%" id="menuTable">
            <!--#
            var firstMenus=@shiro.getPrincipalProperty('firstMenus');
            var secondMenus=@shiro.getPrincipalProperty('secondMenus');
            var customMenu=@shiro.getPrincipalProperty('customMenu');
            #-->
            <!--#for(firstMenu in firstMenus){#-->
            <tr>
                <td width="20%" align="left"><strong><!--#if(lang=="zh_CN"){#-->${firstMenu.name}<!--#}else{#-->${firstMenu.aliasName}<!--#}#--></strong></td>
                <td width="80%" align="left">

                </td>
            </tr>
            <!--# if(!isEmpty(@secondMenus.get(firstMenu.path))){
            for(secondMenu in @secondMenus.get(firstMenu.path)){
            #-->
            <tr>
                <td width="20%" align="left" style="padding-left: 20px;"><!--#if(lang=="zh_CN"){#-->${secondMenu.name}<!--#}else{#-->${secondMenu.aliasName}<!--#}#--></td>
                <td width="80%" align="left">
                    <!--# if(!isEmpty(@secondMenus.get(secondMenu.path))){
                    for(thMenu in @secondMenus.get(secondMenu.path)){ #-->
                    <input type="checkbox" value="${thMenu.id}" onclick="chk()" <!--#if(customMenu!=null&&@customMenu.indexOf(thMenu.id)>-1){#-->checked<!--#}#-->>
                    <!--#if(lang=="zh_CN"){#-->${thMenu.name}<!--#}else{#-->${thMenu.aliasName}<!--#}#-->
                    <!--#}}#-->
                </td>
            </tr>
            <!--#}}#-->
            <!--#}#-->
        </table>
    </div>
</div>
<div class="el-dialog__footer">
        <span class="dialog-footer">
            <button type="button" class="el-button el-button--default" data-dismiss="modal">
                <span>${msg['system.cancel']}</span>
            </button>
            <button type="button" class="el-button el-button--primary" id="okCustom">
                <span>${msg['system.confirm']}</span>
            </button>
        </span>
</div>
<script type="text/javascript">
    function chk(){
        var ids=[];
        $("#menuTable").find("input[type=checkbox]").each(function(){
            if($(this).prop("checked")){
                ids.push($(this).val());
            }
        });
        if(ids.length>5){
            ELEMENT.Message({
                message: "最多可选择5个菜单",
                type: 'error'
            });
            return ids;
        }
        return ids;
    }
    $(function () {
        $("#okCustom").on("click",function(){
            var ids =chk();
            if (ids.length<6) {
                $('#homeDetail').modal('hide');
                $.post("${base}/platform/sys/user/customDo", {ids: ids.toString()}, function (data) {
                    if (data.code == 0) {
                        ELEMENT.Message({
                            message: data.msg,
                            type: 'success'
                        });
                        setTimeout(function () {
                            window.location.reload();
                        },520);
                    } else {
                        ELEMENT.Message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            }
        });
    });
</script>
